package cn.wind.xboot.module.web.controller;

import cn.wind.xboot.core.res.ApiResult;
import cn.wind.xboot.framework.domain.PageVo;
import cn.wind.xboot.logic.app.entity.AppFeedback;
import cn.wind.xboot.logic.app.service.IAppFeedbackService;
import cn.wind.xboot.logic.dto.FeedBackDto;
import cn.wind.xboot.logic.pf.service.IPfPushService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 *消息管理
 * @author WangHao
 * @date 2018-12-28
 */
@Slf4j
@RequestMapping("messageManage")
@Controller
public class MessageController {
    @Autowired
    private IPfPushService pfPushService;
    @Autowired
    private IAppFeedbackService appFeedbackService;


    /**
     *给会员用户极光推送消息
     */
    @RequestMapping("/pushMessage")
    @ResponseBody
    public ApiResult pushMessage(){

        return ApiResult.Custom().success("消息发送成功!");
    }

    /**
     * 会员用户意见反馈列表
     */
    @RequestMapping("/appFeedBackList")
    @ResponseBody
    public ApiResult appFeedBackList(PageVo pageVo,String startDate,String endDate,Integer feedBackStatus){
        Map<String,Object> map = Maps.newHashMap();
        map.put("startDate",startDate);
        map.put("endDate",endDate);
        map.put("feedBackStatus",feedBackStatus);
        IPage<FeedBackDto> page = appFeedbackService.findByCondition(pageVo.init(),map);
        return ApiResult.Custom().success("展示成功").add(page);
    }
    /**
     * 反馈内容详情
     */
    @RequestMapping("/appFeedBackInfo")
    @ResponseBody
    public ApiResult appFeedBackInfo(AppFeedback appFeedback){
        return ApiResult.Custom().success().add(appFeedbackService.getById(appFeedback.getFeedbackId()).getSuggestions());
    }

    /**
     * 回复会员用户的反馈
     */
    @RequestMapping("/answerAppUser")
    @ResponseBody
    public ApiResult answerAppUser(){
        try {

        }catch (Exception e){
            return ApiResult.Custom().failure(e.toString());
        }

        return ApiResult.Custom().success("消息发送成功");
    }


}
